﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Architecture.aspx.cs" Inherits="demo.Pages.Architecture" %>

<%@ Register Assembly="Water" Namespace="Water.Web.Controls" TagPrefix="page" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <style>
        .cnblogs_code
        {
            background-color:#f2f2f2;
            }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <fieldset>
    <legend>架构</legend>
    <ul>
    <li>Water提供了一个多层架构的基础类，如图：
    <img src="../images/water-orm.gif" />
    </li>
    <li>我们只需在相应的层次继承相应的基类(或接口)即可</li>
    <li>以下是以jobs表为例的一个简单demo</li>
    </ul>
    </fieldset>
     <page:Label ID="Label6" runat="server">Jobs表结构：(原是oracle示例数据中的表，后我导入到sql server)</page:Label><br />
     <img src="../images/jobs-table.gif" /><br /><br />
    <!--job entity xml-->
    <page:Label ID="Label1" runat="server">job entity xml配置文件：</page:Label>
<div class="cnblogs_code">
<div>
<span style="color: #000000">&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">entity&nbsp;</span><span style="color: #ff0000">class</span><span style="color: #0000ff">="demo.Objects.Model.JobsInfo"</span><span style="color: #ff0000">&nbsp;table</span><span style="color: #0000ff">="jobs"</span><span style="color: #ff0000">&nbsp;dal-class</span><span style="color: #0000ff">="demo.Objects.DAL.JobsDAL"</span><span style="color: #ff0000">&nbsp;default-orderby-express</span><span style="color: #0000ff">="jobId"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">key-property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jobId"</span><span style="color: #ff0000">&nbsp;column</span><span style="color: #0000ff">="job_id"</span><span style="color: #ff0000">&nbsp;type</span><span style="color: #0000ff">="System.String"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="title"</span><span style="color: #ff0000">&nbsp;column</span><span style="color: #0000ff">="job_title"</span><span style="color: #ff0000">&nbsp;type</span><span style="color: #0000ff">="System.String"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="minSalary"</span><span style="color: #ff0000">&nbsp;column</span><span style="color: #0000ff">="min_salary"</span><span style="color: #ff0000">&nbsp;type</span><span style="color: #0000ff">="System.Double"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="maxSalary"</span><span style="color: #ff0000">&nbsp;column</span><span style="color: #0000ff">="max_salary"</span><span style="color: #ff0000">&nbsp;type</span><span style="color: #0000ff">="System.Double"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">entity</span><span style="color: #0000ff">&gt;</span></div>
</div>
</div>
<p>&nbsp;</p>
<!--jobs model-->
 <page:Label ID="Label2" runat="server">JobsInfo(Model层)：</page:Label>
<div class="cnblogs_code">
<div>
<span style="color: #008080">&nbsp;1</span>&nbsp;<span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System;<br />
</span><span style="color: #008080">&nbsp;2</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System.Collections.Generic;<br />
</span><span style="color: #008080">&nbsp;3</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System.Linq;<br />
</span><span style="color: #008080">&nbsp;4</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System.Web;<br />
</span><span style="color: #008080">&nbsp;5</span>&nbsp;<span style="color: #000000"><br />
</span><span style="color: #008080">&nbsp;6</span>&nbsp;<span style="color: #000000"></span><span style="color: #008000">//</span><span style="color: #008000">导入Water.Architecture2.Model;</span><span style="color: #008000"><br />
</span><span style="color: #008080">&nbsp;7</span>&nbsp;<span style="color: #008000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;Water.Architecture2.Model;<br />
</span><span style="color: #008080">&nbsp;8</span>&nbsp;<span style="color: #000000"><br />
</span><span style="color: #008080">&nbsp;9</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;demo.Objects.Model<br />
</span><span style="color: #008080">10</span>&nbsp;<span style="color: #000000">{<br />
</span><span style="color: #008080">11</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;[Serializable]<br />
</span><span style="color: #008080">12</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;JobsInfo:BaseEntity<br />
</span><span style="color: #008080">13</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;{<br />
</span><span style="color: #008080">14</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;}<br />
</span><span style="color: #008080">15</span>&nbsp;<span style="color: #000000">}</span></div>
</div>
<p>&nbsp;</p>

<!--jobs idal-->
<page:Label ID="Label3" runat="server">IJobsDAL(IDAL层)：</page:Label>
<div class="cnblogs_code">
<div>
<span style="color: #008080">&nbsp;1</span>&nbsp;<span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System;<br />
</span><span style="color: #008080">&nbsp;2</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System.Collections.Generic;<br />
</span><span style="color: #008080">&nbsp;3</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System.Linq;<br />
</span><span style="color: #008080">&nbsp;4</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System.Text;<br />
</span><span style="color: #008080">&nbsp;5</span>&nbsp;<span style="color: #000000"><br />
</span><span style="color: #008080">&nbsp;6</span>&nbsp;<span style="color: #000000"></span><span style="color: #008000">//</span><span style="color: #008000">导入Water&nbsp;framework中Water.Architecture2.IDAL;</span><span style="color: #008000"><br />
</span><span style="color: #008080">&nbsp;7</span>&nbsp;<span style="color: #008000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;Water.Architecture2.IDAL;<br />
</span><span style="color: #008080">&nbsp;8</span>&nbsp;<span style="color: #000000"></span><span style="color: #008000">//</span><span style="color: #008000">导入当前应用Model</span><span style="color: #008000"><br />
</span><span style="color: #008080">&nbsp;9</span>&nbsp;<span style="color: #008000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;demo.Objects.Model;<br />
</span><span style="color: #008080">10</span>&nbsp;<span style="color: #000000"><br />
</span><span style="color: #008080">11</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;demo.Objects.IDAL<br />
</span><span style="color: #008080">12</span>&nbsp;<span style="color: #000000">{<br />
</span><span style="color: #008080">13</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">interface</span><span style="color: #000000">&nbsp;IJobsDAL:IBaseDAL</span><span style="color: #000000">&lt;</span><span style="color: #000000">JobsInfo</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br />
</span><span style="color: #008080">14</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;{<br />
</span><span style="color: #008080">15</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;}<br />
</span><span style="color: #008080">16</span>&nbsp;<span style="color: #000000">}<br />
</span><span style="color: #008080">17</span>&nbsp;<span style="color: #000000"></span></div>
</div>
<p>&nbsp;</p>

<!--jobs dal-->
<page:Label ID="Label4" runat="server">JobsDAL(DAL层)：</page:Label>
<div class="cnblogs_code">
<div>
<span style="color: #008080">&nbsp;1</span>&nbsp;<span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System;<br />
</span><span style="color: #008080">&nbsp;2</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System.Collections.Generic;<br />
</span><span style="color: #008080">&nbsp;3</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System.Linq;<br />
</span><span style="color: #008080">&nbsp;4</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System.Web;<br />
</span><span style="color: #008080">&nbsp;5</span>&nbsp;<span style="color: #000000"><br />
</span><span style="color: #008080">&nbsp;6</span>&nbsp;<span style="color: #000000"></span><span style="color: #008000">//</span><span style="color: #008000">导入Water&nbsp;framework中Water.Architecture2.DAL;</span><span style="color: #008000"><br />
</span><span style="color: #008080">&nbsp;7</span>&nbsp;<span style="color: #008000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;Water.Architecture2.DAL;<br />
</span><span style="color: #008080">&nbsp;8</span>&nbsp;<span style="color: #000000"></span><span style="color: #008000">//</span><span style="color: #008000">导入当前应用Model</span><span style="color: #008000"><br />
</span><span style="color: #008080">&nbsp;9</span>&nbsp;<span style="color: #008000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;demo.Objects.Model;<br />
</span><span style="color: #008080">10</span>&nbsp;<span style="color: #000000"></span><span style="color: #008000">//</span><span style="color: #008000">导入当前应用IDAL</span><span style="color: #008000"><br />
</span><span style="color: #008080">11</span>&nbsp;<span style="color: #008000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;demo.Objects.IDAL;<br />
</span><span style="color: #008080">12</span>&nbsp;<span style="color: #000000"><br />
</span><span style="color: #008080">13</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;demo.Objects.DAL<br />
</span><span style="color: #008080">14</span>&nbsp;<span style="color: #000000">{<br />
</span><span style="color: #008080">15</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;JobsDAL:BaseDAL</span><span style="color: #000000">&lt;</span><span style="color: #000000">JobsInfo</span><span style="color: #000000">&gt;</span><span style="color: #000000">,IJobsDAL<br />
</span><span style="color: #008080">16</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;{<br />
</span><span style="color: #008080">17</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;}<br />
</span><span style="color: #008080">18</span>&nbsp;<span style="color: #000000">}</span></div>
</div>
<p>&nbsp;</p>

<!--jobs bll-->
<page:Label ID="Label5" runat="server">Jobs(BLL层)：</page:Label>
<div class="cnblogs_code">
<div><span style="color: #008080">&nbsp;1</span>&nbsp;<span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System;<br />
</span><span style="color: #008080">&nbsp;2</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System.Collections.Generic;<br />
</span><span style="color: #008080">&nbsp;3</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System.Linq;<br />
</span><span style="color: #008080">&nbsp;4</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;System.Web;<br />
</span><span style="color: #008080">&nbsp;5</span>&nbsp;<span style="color: #000000"><br />
</span><span style="color: #008080">&nbsp;6</span>&nbsp;<span style="color: #000000"></span><span style="color: #008000">//</span><span style="color: #008000">导入Water&nbsp;framework中Water.Architecture2.BLL;</span><span style="color: #008000"><br />
</span><span style="color: #008080">&nbsp;7</span>&nbsp;<span style="color: #008000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;Water.Architecture2.BLL;<br />
</span><span style="color: #008080">&nbsp;8</span>&nbsp;<span style="color: #000000"></span><span style="color: #008000">//</span><span style="color: #008000">导入当前应用Model</span><span style="color: #008000"><br />
</span><span style="color: #008080">&nbsp;9</span>&nbsp;<span style="color: #008000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;demo.Objects.Model;<br />
</span><span style="color: #008080">10</span>&nbsp;<span style="color: #000000"></span><span style="color: #008000">//</span><span style="color: #008000">导入当前应用IDAL</span><span style="color: #008000"><br />
</span><span style="color: #008080">11</span>&nbsp;<span style="color: #008000"></span><span style="color: #0000ff">using</span><span style="color: #000000">&nbsp;demo.Objects.IDAL;<br />
</span><span style="color: #008080">12</span>&nbsp;<span style="color: #000000"><br />
</span><span style="color: #008080">13</span>&nbsp;<span style="color: #000000"></span><span style="color: #0000ff">namespace</span><span style="color: #000000">&nbsp;demo.Objects.BLL<br />
</span><span style="color: #008080">14</span>&nbsp;<span style="color: #000000">{<br />
</span><span style="color: #008080">15</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;Jobs:BaseBLL</span><span style="color: #000000">&lt;</span><span style="color: #000000">JobsInfo,IJobsDAL</span><span style="color: #000000">&gt;</span><span style="color: #000000"><br />
</span><span style="color: #008080">16</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;{<br />
</span><span style="color: #008080">17</span>&nbsp;<span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;}<br />
</span><span style="color: #008080">18</span>&nbsp;<span style="color: #000000">}</span></div>
</div>
<p>&nbsp;</p>
<div>经过上面的步骤我们关于jobs的多层架构就实现了，可以发现</div>
<img src="../images/jobs-bll.gif">
<div>Jobs类内有各种各样关于操作Jobs的方法且都是virtual的，对于很复杂的需求我们可以对其override。</div>





    </div>
    </form>
</body>
</html>
